-
Notifications
You must be signed in to change notification settings - Fork 2
Add react router links to Breadcrumbs #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't work "out of the box" for me when I used it in my external app, because I didn't have <BrowserRouter>
added.
I'm not sure how to handle this. Maybe we could add it to some-kind of <SciReactProvider/>
(which could also embed the theme) so that just the one line can be added in external apps. Something like:
const SciReactUIProvider = function ({children}) {
return (
<ThemeProvider>
<BrowserRouter>
{children}
</BrowserRouter>
</ThemeProvider>
);
};
The alternative is to just add it to the docs but I like to hide, behind the scenes, as much as we can What do you think?
We could create the SciReactUIProvider which would leave the Breadcrumbs component unchanged and would leave the option for people to use e.g. RouterProvider in place of BrowserProvider together withe the ThemeProvider. I should still update the docs with something. |
I thought we still had to change Breadcrumbs to use ReactRouter's |
My comment was unclear! I mean leave the Breadcrumbs component unchanged from how it is in this PR. |
0aaff20
to
efb296e
Compare
I've added SciReactUIProvider and updated the docs to replace ThemeProvider with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few minor suggestions.
The |
Also, we need an export in index.ts:
|
I was a bit stuck on where to put it. |
Maybe it's time to reorganise the component folder... controls, sections, general ? |
Are we sure we want to add a dependency to a specific routing library? Or has Diamond made a decision on which we should use? |
As far as I know there's no Diamond-wide decision on which we should use. I do think react-router is a good choice and what we should use here. I don't see a reason to diverge with multiple options. |
I think allowing people to do component "impersonation" in the breadcrumbs component is not going to lead to diversion, it would be useful for the following reasons:
|
I could change the Breadcrumbs component and pass a LinkComponent e.g.
Then this can be used with whatever routing library e.g. Link from react-router-dom/ next etc. |
Shall we go with component/controls and component/navigation to mirror the storybook. I quite like those categories. |
I think this is a nice solution (to allow users to set both the link component and the prop each breadcrumb would use in that link component), and removing the provider surely would make things easier in the future! |
e9e653a
to
6ad9e23
Compare
6ad9e23
to
1a36fe7
Compare
Adds LinkComponent prop for page routing. Closes #56.
Reorganises components to mirror Storybook component structure.
Fixes type issue with image in Footer and Navbar.
I had to add yet another config file to get the tests running due to an issue with react-router-dom v7. See here and here.